#include <iostream>
#include <math.h>

using namespace std;
typedef unsigned long long BIG;

int main()
{
	const BIG X = 1999999;
    BIG i = 3, j, n = 2, d, result = 5;
    BIG * p = new BIG[X/2];
    p[0] = 2;
    p[1] = 3;
    while(i < X)
    {
        d = BIG(sqrt(i+=2));
        j = 1;
        while(d >= p[j] && i%p[j]) j++;
        if(d < p[j])
        {
        	p[n++] = i;
        	result += i;
        }
    }
    cout << result << endl;
};
